import { Module, NestModule, MiddlewaresConsumer } from '@nestjs/common';
import { AppController } from './app.controller';
// import { ElasticController } from './controller/elasticsearch.controller';
import { LoggerMiddleware } from './middleware/logger.middleware';
import { ElasticModule } from './modules/elasticsearch.module';
/**
 * 主模块
 *
 * @export
 * @class AppModule
 * @implements {NestModule}
 */
@Module({
  imports: [ElasticModule], // 导入ElasticModule副模块
  controllers: [AppController], // 导入AppController控制层
  components: [],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewaresConsumer): void {
    consumer
      .apply(LoggerMiddleware) // 应用中间件
      .with('AppController') // 中间件应用到AppController
      .forRoutes(AppController); // 应用AppController的所有路由上
  }
}
